package com.kalix.jyksh.record.biz;

import com.kalix.framework.core.impl.biz.GenericBizServiceImpl;
import com.kalix.framework.core.util.ConfigUtil;
import com.kalix.ksh.record.api.biz.IManagementObjectRecordBeanService;
import com.kalix.ksh.record.api.dao.IManagementObjectRecordBeanDao;
import com.kalix.ksh.record.api.model.ToInterface;
import com.kalix.jyksh.record.entities.ManagementObjectRecordBean;
import org.json.JSONArray;
import org.json.JSONObject;

/**
 *
 * 功能描述: 被管理对象返回数据
 *
 * @auther: Whw
 * @date: 2019/1/14 0014 17:15
 * @param:
 * @return:
 */
public class ManagementObjectRecordServiceImpl extends GenericBizServiceImpl<IManagementObjectRecordBeanDao, ManagementObjectRecordBean> implements IManagementObjectRecordBeanService {
    public ManagementObjectRecordServiceImpl(){

        super.init(ManagementObjectRecordBean.class.getName());
    }
    public static String wsIp = (String) ConfigUtil.getConfigProp("FREEBOARD_IP","config.ksh.portconf");
    public static String wsPort =(String)ConfigUtil.getConfigProp("FREEBOARD_PORT","config.ksh.portconf");


    public String insertAll() {
        String data=ToInterface.interfaceUtil("http://"+wsIp+":"+wsPort+"/om/statistics/category","");
        JSONArray jsonObject = new JSONArray(data);
        JSONObject job = jsonObject.getJSONObject(0);
        Object middleware =  job.get("middleware");//中间件
        Object host =  job.get("host");//主机
        Object database =  job.get("database");//数据库
        Object network =  job.get("network");//网络
        Object service =  job.get("service");//标准应用

        JSONArray jsonArray = new JSONArray();
        jsonArray.put("网络设备");
        jsonArray.put("主机设备");
        jsonArray.put("数据库量");
        jsonArray.put("标准应用");
//        jsonArray.put("中间件");
        JSONArray json = new JSONArray();
        json.put(network);
        json.put(host);
        json.put(database);
        json.put(service);
//        json.put(middleware);
        JSONArray js = new JSONArray();
        js.put(jsonArray);
        js.put(json);

        return js.toString();
    }
}
